package com.example.a14110100420.yuejian.WAdapter.club;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.a14110100420.yuejian.R;
import com.example.a14110100420.yuejian.Wbean.club.ClubCourse;

import java.util.List;

/**
 * Created by wanger on 2017/11/14.
 */

public class ClubCoureAdapter extends RecyclerView.Adapter {
    private View view;
    private Context context;
    private List list;
    private LayoutInflater inflater;

    public ClubCoureAdapter(Context context,List list){
        this.context = context;
        this.list = list;
        inflater =  LayoutInflater.from(context);

    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        view = inflater.from(parent.getContext()).inflate(R.layout.fragment_club__course_,parent,false);
        ClubCourseViewHolder viewHolder = new ClubCourseViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ClubCourseViewHolder viewHolder = (ClubCourseViewHolder) holder;
        ClubCourse.ClubcourseEntity clubCourse = (ClubCourse.ClubcourseEntity) list.get(position);
        if (null == clubCourse){
            return;
        }
        viewHolder.course_name.setText(clubCourse.getCourse_name());
        viewHolder.course_class.setText(clubCourse.getBmnotice());
        viewHolder.course_price.setText(clubCourse.getCourse_price());


    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    private class ClubCourseViewHolder extends RecyclerView.ViewHolder{
        public TextView course_name;
        public TextView course_class;
        public TextView course_price;
        public View itemView;
        public ClubCourseViewHolder(View itemView) {
            super(itemView);
            this.itemView=itemView;

            course_class = itemView.findViewById(R.id.course_intro);
            course_name = itemView.findViewById(R.id.course_name);
            course_price = itemView.findViewById(R.id.course_price);
        }
    }
}
